<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>CMU462 Library: /Users/Sky/Dropbox/Projects/CMU462/private/p3/CMU462/include/CMU462/vector3D.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMU462 Library
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">Computer Graphics</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_93cde9e1f49b119e2b24d2ae2dcc682a.html">CMU462</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">vector3D.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CMU462_VECTOR3D_H</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CMU462_VECTOR3D_H</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;CMU462.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;ostream&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_c_m_u462.html">CMU462</a> {</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html">   14</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_c_m_u462_1_1_vector3_d.html">Vector3D</a> {</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;  <span class="comment">// components</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;  <span class="keywordtype">double</span> x, y, z;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">   24</a></span>&#160;  <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>() : x( 0.0 ), y( 0.0 ), z( 0.0 ) { }</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#a28d8a8458b6f51fc6e4a4a2b85cb04f7">   30</a></span>&#160;  <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a28d8a8458b6f51fc6e4a4a2b85cb04f7">Vector3D</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> z) : x( x ), y( y ), z( z ) { }</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#ac9b4ec5c0d714b1044f0290259aeb0fa">   36</a></span>&#160;  <a class="code" href="class_c_m_u462_1_1_vector3_d.html#ac9b4ec5c0d714b1044f0290259aeb0fa">Vector3D</a>( <span class="keywordtype">double</span> c ) : x( c ), y( c ), z( c ) { }</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#a9b64991b7b149d83809976ab453f130a">   42</a></span>&#160;  <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a9b64991b7b149d83809976ab453f130a">Vector3D</a>( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html">Vector3D</a>&amp; v ) : x( v.x ), y( v.y ), z( v.z ) { }</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <span class="comment">// returns reference to the specified component (0-based indexing: x, y, z)</span></div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">double</span>&amp; operator[] ( <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; index ) {</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordflow">return</span> ( &amp;x )[ index ];</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;  }</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  <span class="comment">// returns const reference to the specified component (0-based indexing: x, y, z)</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; operator[] ( <span class="keyword">const</span> <span class="keywordtype">int</span>&amp; index )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keywordflow">return</span> ( &amp;x )[ index ];</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  }</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator==( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>&amp; v)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <span class="keywordflow">return</span> v.x == x &amp;&amp; v.y == y &amp;&amp; v.z == z;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  }</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  <span class="comment">// negation</span></div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a> operator-( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( -x, -y, -z );</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  }</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="comment">// addition</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a> operator+( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>&amp; v )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( x + v.x, y + v.y, z + v.z );</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  }</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  <span class="comment">// subtraction</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a> operator-( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>&amp; v )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( x - v.x, y - v.y, z - v.z );</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <span class="comment">// right scalar multiplication</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a> operator*( <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; c )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( x * c, y * c, z * c );</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;  }</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  <span class="comment">// scalar division</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a> operator/( <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; c )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">double</span> rc = 1.0/c;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( rc * x, rc * y, rc * z );</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="comment">// addition / assignment</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> operator+=( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>&amp; v ) {</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    x += v.x; y += v.y; z += v.z;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  }</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  <span class="comment">// subtraction / assignment</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> operator-=( <span class="keyword">const</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>&amp; v ) {</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    x -= v.x; y -= v.y; z -= v.z;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  }</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  <span class="comment">// scalar multiplication / assignment</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> operator*=( <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; c ) {</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    x *= c; y *= c; z *= c;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  }</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  <span class="comment">// scalar division / assignment</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> operator/=( <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; c ) {</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    (*this) *= ( 1./c );</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;  }</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;</div>
<div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#a00863ae9c1d295b563ca3d792337759d">  107</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a00863ae9c1d295b563ca3d792337759d">norm</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keywordflow">return</span> sqrt( x*x + y*y + z*z );</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  }</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#a40299da4db79bfd683bff773fff56003">  114</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a40299da4db79bfd683bff773fff56003">norm2</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">return</span> x*x + y*y + z*z;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;  }</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div>
<div class="line"><a name="l00121"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#ade58b0e3fdaa28e083595f1350c71c7f">  121</a></span>&#160;  <span class="keyword">inline</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html">Vector3D</a> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#ade58b0e3fdaa28e083595f1350c71c7f">unit</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordtype">double</span> rNorm = 1. / sqrt( x*x + y*y + z*z );</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">Vector3D</a>( rNorm*x, rNorm*y, rNorm*z );</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;  }</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div>
<div class="line"><a name="l00129"></a><span class="lineno"><a class="line" href="class_c_m_u462_1_1_vector3_d.html#ae406ad4e421d9537b55c1a3fd3475727">  129</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_c_m_u462_1_1_vector3_d.html#ae406ad4e421d9537b55c1a3fd3475727">normalize</a>( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    (*this) /= <a class="code" href="class_c_m_u462_1_1_vector3_d.html#a00863ae9c1d295b563ca3d792337759d">norm</a>();</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  }</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;}; <span class="comment">// class Vector3D</span></div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;<span class="comment">// left scalar multiplication</span></div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;<span class="keyword">inline</span> Vector3D operator* ( <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; c, <span class="keyword">const</span> Vector3D&amp; v ) {</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;  <span class="keywordflow">return</span> Vector3D( c * v.x, c * v.y, c * v.z );</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;}</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="comment">// dot product (a.k.a. inner or scalar product)</span></div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;<span class="keyword">inline</span> <span class="keywordtype">double</span> dot( <span class="keyword">const</span> Vector3D&amp; u, <span class="keyword">const</span> Vector3D&amp; v ) {</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  <span class="keywordflow">return</span> u.x*v.x + u.y*v.y + u.z*v.z ;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;}</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="comment">// cross product</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="keyword">inline</span> Vector3D cross( <span class="keyword">const</span> Vector3D&amp; u, <span class="keyword">const</span> Vector3D&amp; v ) {</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;  <span class="keywordflow">return</span> Vector3D( u.y*v.z - u.z*v.y,</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;                   u.z*v.x - u.x*v.z,</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;                   u.x*v.y - u.y*v.x );</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;}</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;<span class="comment">// prints components</span></div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;std::ostream&amp; operator&lt;&lt;( std::ostream&amp; os, <span class="keyword">const</span> Vector3D&amp; v );</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;} <span class="comment">// namespace CMU462</span></div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">#endif // CMU462_VECTOR3D_H</span></div>
<div class="ttc" id="namespace_c_m_u462_html"><div class="ttname"><a href="namespace_c_m_u462.html">CMU462</a></div><div class="ttdef"><b>Definition:</b> CMU462.h:8</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html">CMU462::Vector3D</a></div><div class="ttdoc">Defines 3D vectors. </div><div class="ttdef"><b>Definition:</b> vector3D.h:14</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_ade58b0e3fdaa28e083595f1350c71c7f"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#ade58b0e3fdaa28e083595f1350c71c7f">CMU462::Vector3D::unit</a></div><div class="ttdeci">Vector3D unit(void) const </div><div class="ttdoc">Returns unit vector. </div><div class="ttdef"><b>Definition:</b> vector3D.h:121</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_a00863ae9c1d295b563ca3d792337759d"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#a00863ae9c1d295b563ca3d792337759d">CMU462::Vector3D::norm</a></div><div class="ttdeci">double norm(void) const </div><div class="ttdoc">Returns Euclidean length. </div><div class="ttdef"><b>Definition:</b> vector3D.h:107</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_a28d8a8458b6f51fc6e4a4a2b85cb04f7"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#a28d8a8458b6f51fc6e4a4a2b85cb04f7">CMU462::Vector3D::Vector3D</a></div><div class="ttdeci">Vector3D(double x, double y, double z)</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> vector3D.h:30</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_a40299da4db79bfd683bff773fff56003"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#a40299da4db79bfd683bff773fff56003">CMU462::Vector3D::norm2</a></div><div class="ttdeci">double norm2(void) const </div><div class="ttdoc">Returns Euclidean length squared. </div><div class="ttdef"><b>Definition:</b> vector3D.h:114</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_ae406ad4e421d9537b55c1a3fd3475727"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#ae406ad4e421d9537b55c1a3fd3475727">CMU462::Vector3D::normalize</a></div><div class="ttdeci">void normalize(void)</div><div class="ttdoc">Divides by Euclidean length. </div><div class="ttdef"><b>Definition:</b> vector3D.h:129</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_a9b64991b7b149d83809976ab453f130a"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#a9b64991b7b149d83809976ab453f130a">CMU462::Vector3D::Vector3D</a></div><div class="ttdeci">Vector3D(const Vector3D &amp;v)</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> vector3D.h:42</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_a364bf2470fc8ebbcf21ae78d5e5bcf18"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#a364bf2470fc8ebbcf21ae78d5e5bcf18">CMU462::Vector3D::Vector3D</a></div><div class="ttdeci">Vector3D()</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> vector3D.h:24</div></div>
<div class="ttc" id="class_c_m_u462_1_1_vector3_d_html_ac9b4ec5c0d714b1044f0290259aeb0fa"><div class="ttname"><a href="class_c_m_u462_1_1_vector3_d.html#ac9b4ec5c0d714b1044f0290259aeb0fa">CMU462::Vector3D::Vector3D</a></div><div class="ttdeci">Vector3D(double c)</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> vector3D.h:36</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Oct 10 2015 03:34:42 for CMU462 Library by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
